@tailwind base;
@tailwind components;
@tailwind utilities;

#root {
    --primary: #eeeff4;
    --secondary: #f6f8fc;
}

body {
    margin: 0;
    padding: 0;
}

html, body, #root {
    @apply h-full;
}

a {
    text-decoration: none;
    color: inherit;
}

.layoutRoot {
    @apply pt-12;
}

.title_bar {
    z-index: 300;
    top: 0;
    left: 0;
    width: 100%;
    -webkit-app-region: drag;
    background: var(--primary);
    @apply fixed h-12 items-center flex;
}

.main_window {
    padding-left: 270px;
}

.main_sidebar {
    position: fixed;
    left: 0;
    background: var(--secondary);
    color: #202124;
    overflow-y: auto;
    z-index: 200;
    @apply w-[270px] h-full pr-3 pt-3 pb-3 shrink-0;
}

.slide-button {
    display: none;
}

.page-detail-modal {
    @apply w-[1500px] p-4;
}

/* 详情页布局容器 */
.page-detail-layout {
    @apply pl-2 pr-2;
    display: flex;
    justify-content: center;
    width: 100%;
}

/* 内容区域wrapper - 用于居中内容 */
.page-detail-content-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}

/* 左侧占位区域 - 与目录区域宽度相同，用于居中 */
.page-detail-spacer {
    width: 240px;
    flex-shrink: 0;
}

/* 操作栏置顶 - 模态窗口中 */
.page-detail-modal .page-detail-header {
    position: sticky;
    top: 0;
    z-index: 40;
}

/* 操作栏置顶 - 独立页面中，考虑顶部导航栏高度 (48px) */
.main_window .page-detail-header {
    position: sticky;
    top: 48px;
    z-index: 40;
}

/* 目录区域样式 - 模态窗口中 */
.page-detail-modal .page-detail-toc-area {
    width: 240px;
    flex-shrink: 0;
    padding-left: 20px;
    position: sticky;
    top: 26px;
    align-self: flex-start;
}

/* 目录区域样式 - 独立页面中，考虑顶部导航栏高度 */
.main_window .page-detail-toc-area {
    width: 240px;
    flex-shrink: 0;
    padding-left: 20px;
    position: sticky;
    top: 64px;
    align-self: flex-start;
}

/* 目录外层容器 */
.toc-wrapper {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 100px);
    padding-top: 24px;
}

/* 目录导航区域 - 只有这部分滚动 */
.toc-nav {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.3) transparent;
    border-left: 1px solid #e5e7eb;
}

.toc-nav::-webkit-scrollbar {
    width: 4px;
}

.toc-nav::-webkit-scrollbar-track {
    background: transparent;
}

.toc-nav::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.3);
    border-radius: 2px;
}

.toc-nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.6);
}

/* 目录列表 */
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin: 0;
}

/* 目录链接 */
.toc-link {
    display: block;
    padding: 6px 0 6px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: #6b7280;
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
}

.toc-link:hover {
    color: #374151;
    border-left-color: #d1d5db;
}

.toc-link-active {
    color: #2563eb;
    border-left-color: #2563eb;
    font-weight: 500;
}

@media (min-width: 1800px) {
    .page-detail-modal {
        @apply w-[1600px];
    }
}

@media (max-width: 1500px) {
    .page-detail-modal {
        @apply w-[1300px];
    }
}

@media (max-width: 1300px) {
    .page-detail-modal {
        @apply w-[1100px];
    }
    
    .page-detail-toc-area,
    .page-detail-spacer {
        display: none !important;
    }
}

@media (max-width: 1100px) {
    .page-detail-modal {
        @apply w-[900px];
    }
}

@media (max-width: 900px) {
    .page-detail-modal {
        @apply w-[100%];
    }

    .page-detail-paper {
        width: 100%;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .logo-area {
        position: relative;
    }

    .setting-area {
        position: relative;
    }

    .logo-text {
        display: none;
    }

    .search-box {
        min-width: 0;
        @apply grow;
    }

    .slide-button {
        display: block;
    }

    .main_window {
        padding-left: 0;
    }

    #root .main_sidebar {
        display: none;
    }

    #root.toggle-sidebar .main_sidebar {
        display: block !important;
    }

    #root.toggle-sidebar .main_window {
        padding-left: 270px;
    }

    .page-list {
        width: 100%;
    }

    .page-item-thumb {
        width: 100px !important;
        height: 100px !important;
    }

    .filter-options {
        display: none;
    }
}

@media screen and (max-width: 950px) {
    #root.toggle-sidebar .main_window {
        padding-left: 0;
    }
}

.main_sidebar::-webkit-scrollbar, .scrollbar::-webkit-scrollbar {
    width: 8px;
}

.main_sidebar::-webkit-scrollbar-track, .scrollbar::-webkit-scrollbar-track {
    background-color: transparent;
}

.main_sidebar::-webkit-scrollbar-thumb, .scrollbar::-webkit-scrollbar-thumb {
    background-color: #d6dee1;
    border-radius: 8px;
    background-clip: content-box;
}

.main_sidebar::-webkit-scrollbar-thumb:hover, .scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #a8bbbf;
}

.search-wrapper {
    -webkit-app-region: no-drag;
    @apply flex justify-center grow;
}

.nodrag {
    -webkit-app-region: no-drag;
}

.btn-size-ctrl {
    -webkit-app-region: no-drag;
    @apply border-0 bg-transparent hover:bg-slate-200 h-11 w-11;
}

.btn-size-ctrl svg {
    @apply w-[0.6rem] h-[0.6rem];
}

.btn-size-close {
    @apply hover:bg-red-400;
}

.subheader {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    @apply sticky top-12;
}

.separator {
    display: flex;
    align-items: center;
    text-align: center;
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ccc;
}

.separator:not(:empty)::before {
    margin-right: .25em;
}

.separator:not(:empty)::after {
    margin-left: .25em;
}